package org.springcloud.wisdom.springcloud_03_freshman.student.controller;

import org.springcloud.wisdom.springcloud_03_freshman.common.bean.ResponseData;
import org.springcloud.wisdom.springcloud_03_freshman.common.controller.BaseController;
import org.springcloud.wisdom.springcloud_03_freshman.index.login.entity.Freshman;
import org.springcloud.wisdom.springcloud_03_freshman.student.service.FreshmanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("/fresh")
public class FreshmanController  extends BaseController {
    @Autowired
    FreshmanService freshmanService;

    /**
     * 根据adsno来查询新生信息
     * @param adsno 录取通知书编号
     * @return
     */
    @GetMapping("/get")
    public ResponseData<Object> getFreshmanByAdsno(@RequestParam("adsno") String adsno){
        return returnObject(freshmanService.getFresh(adsno));
    }

    /**
     * 更新信息
     * @param freshman 新生实体类
     * @return
     */
    @PutMapping("/update")
    public ResponseData<Object> updateFreshman(@RequestBody Freshman freshman){
        return returnObject(freshmanService.update(freshman));
    }
}
